LLLR Parsing: a Combination of LL and LR Parsing
نویسنده
چکیده
A new parsing method called LLLR parsing is defined and a method for producing LLLR parsers is described. An LLLR parser uses an LL parser as its backbone and parses as much of its input string using LL parsing as possible. To resolve LL conflicts it triggers small embedded LR parsers. An embedded LR parser starts parsing the remaining input and once the LL conflict is resolved, the LR parser produces the left parse of the substring it has just parsed and passes the control back to the backbone LL parser. The LLLR(k) parser can be constructed for any LR(k) grammar. It produces the left parse of the input string without any backtracking and, if used for a syntax-directed translation, it evaluates semantic actions using the top-down strategy just like the canonical LL(k) parser. An LLLR(k) parser is appropriate for grammars where the LL(k) conflicting nonterminals either appear relatively close to the bottom of the derivation trees or produce short substrings. In such cases an LLLR parser can perform a significantly better error recovery than an LR parser since the most part of the input string is parsed with the backbone LL parser. LLLR parsing is similar to LL(∗) parsing except that it (a) uses LR(k) parsers instead of finite automata to resolve the LL(k) conflicts and (b) does not perform any backtracking. 1998 ACM Subject Classification F.4.2 Grammars and Other Rewriting Systems (Parsing), D.3.1 Formal Definitions and Theory (Syntax), D.3.4 Processors (Parsing)
منابع مشابه
Unifying LL and LR parsing
In parsing theory, LL parsing and LR parsing are regarded to be two distinct methods. In this paper the relation between these methods is cla-riied. As shown in literature on parsing theory, for every context-free grammar, a so-called non-deterministic LR(0) automaton can be constructed. Here, we show, that traversing this automaton in a special way is equivalent to LL(1) parsing. This automato...
متن کاملLr Parsing = Grammar Transformation + Ll Parsing Making Lr Parsing More Understandable and More Eecient
The paper has three aims. Its primary focus is a derivation method which is | in contrast to many of the classical presentations in the literature | easy to comprehend and thus easy to adapt to di erent needs. Secondly, it presents an improved LR parser which has the power of LR parsing, but (almost) the e ciency of LALR parsing. Finally, it elucidates the strong conceptual relationships that a...
متن کاملCh(k) Grammars: A Characterization of LL(k) Languages
From the point of view of parsing the LL(K] grammars constitute a very attractive class of context-free grammars. For each LL{K] grammar a top-down parsing algorithm can be devised which is essentially a one-state deterministic push-down automaton. From a more theoretiG point of view LL[K) grammars are attractive as well. It is well-known, for example, that it is decidable whether two LLfk) gra...
متن کاملSimple Chain Grammars
A subclass of the LR(0)-grammars, the class of simple chain grammars is introduced. Although there exist simple chain gr~ars which are not LL(k) for any k, this new class of grammars is very close related to the class of LL(1) and simple LL(1) grammars. In fact it can be proved (not in this paper) that each simple chain grammar has an equivalent simple LL(1) grammar. A very simple (bottom-up) p...
متن کاملAn Incremental LR Parse Strategy for Language - Based EditorsPhil
We present an incremental parser for a modeless syntax recognising language-based editor. The strategy we describe has been implemented as part of the UQ? generic language-based environment. Incremental parsing in the UQ? editor has previously been based on LL techniques. The incremen-tal LR parser described in this report has been developed to allow manipulation of a larger class of languages ...
متن کامل